/*
 * @Author: szx
 * @Date: 2022-05-22 15:38:19
 * @LastEditTime: 2022-05-22 15:47:39
 * @Description:
 * @FilePath: \leetcode\面试题\08\05\05.js
 */
/**
 * @param {number} A
 * @param {number} B
 * @return {number}
 */
var multiply = function (A, B) {
    if (A == 0 || B == 0) return 0;
    if (B == 1) return A;
    if (A == 1) return B;
    return multiply(A, B - 1) + A;
};

var multiply = function (A, B) {
    if (B) {
        if (B & 1) return multiply(A << 1, B >> 1) + A;
        else return multiply(A << 1, B >> 1);
    }
    return 0;
};
var multiply = function (A, B) {
    return B ? multiply(A << 1, B >> 1) + (B & 1 ? A : 0) : 0;
};
